import { createApp } from 'vue';
import Antd from 'ant-design-vue';

import '@/assets/css/index.less';
import App from './App.vue';
import router from './router';
import store from './config/store';

const app = createApp(App);
app.use(store);
app.use(router);
app.use(Antd);
app.mount('#app');

// qiankun设置注册
import {
  registerMicroApps,
  childProjectAll,
  mainProps,
  start,
} from '@/qiankun';

const Apps = childProjectAll('main-antd', { ...mainProps(router, store) });
console.log('Apps的数据');

console.log(Apps);

registerMicroApps(Apps, {
  beforeLoad: [
    async (app) => {
      store.commit('global/setQiankunStartLoading', true);
      console.log('before load app.name====>>>>>', app.name);
    },
  ],
  beforeMount: [
    async (app) => {
      store.commit('global/setQiankunStartLoading', true);
      console.log('[LifeCycle] before mount %c%s', 'color: green;', app.name);
    },
  ],
  afterMount: [
    async (app) => {
      store.commit('global/setQiankunStartLoading', false);
      console.log('[LifeCycle] after mount %c%s', 'color: green;', app.name);
    },
  ],
  afterUnmount: [
    async (app) => {
      console.log('[LifeCycle] after unmount %c%s', 'color: green;', app.name);
    },
  ],
});
